﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.WEB;
using DataAccess;
using Model;

namespace AirlinePilotAcedemy_WEB
{
    public partial class ViewScores : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            User user = UserDataAccess.GetUserByUsername(User.Identity.Name);

            this.codMateriaTB.Text = Request["codMateria"];
            this.subjectNameTB.Text = Request["nameSubject"];
            this.monthTB.Text = Request["month"];
            GridView1.DataSource = ViewSubjectsManager.GetSubjectScores(Convert.ToInt64(codMateriaTB.Text), user.Ci);
            GridView1.DataBind();
            GridViewRow row = GridView1.Rows[0];
            this.finalScoreL.Text = GetFinalScore(Convert.ToInt16(row.Cells[0].Text), Convert.ToInt16(row.Cells[1].Text), Convert.ToInt16(row.Cells[2].Text));

        }
        private string GetFinalScore(int s1, int s2, int s3)
        {
            return ((s1 + s2 + s3) / 3).ToString();
        }
    }
}